﻿using Microsoft.AspNetCore.Mvc;
using Nx.Models;
using Nx.Filter;
using System.Diagnostics;

namespace Nx.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        [RedisNx(TimeoutSeconds = 60)]
        public IActionResult Index()
        {
            return View();
        }

        [RedisNx]
        public IActionResult Submit()
        {
            return Content("ok");
        }

        [RedisNx("{Param.a}")]
        public IActionResult Submit2(SubmitModel model)
        {
            return Content("ok");
        }

        /// <summary>
        /// 提交时需要 contentType: application/json
        /// </summary>
        /// <param name="mpodel"></param>
        /// <returns></returns>
        [RedisNx("{Param.a}_{Param.b}", Delete = false)]
        public IActionResult Submit3([FromBody] SubmitModel model)
        {
            return Content("ok");
        }

    }
}